package com.bplow.deep.sysmng.directive;

import java.io.IOException;
import java.io.Writer;

import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.SimpleNode;

/**
 * 生成菜单
 * 
 * @author wangxiaolei
 * @version $Id: MenuDirective.java, v 0.1 2017年4月14日 下午5:16:56 wangxiaolei Exp $
 */
public class MenuDirective extends Directive{

    @Override
    public String getName() {
        return "menuDirective";
    }

    @Override
    public int getType() {
        return LINE;
    }

    @Override
    public boolean render(InternalContextAdapter context, Writer writer, Node node)
                                                                                   throws IOException,
                                                                                   ResourceNotFoundException,
                                                                                   ParseErrorException,
                                                                                   MethodInvocationException {
        SimpleNode sn_region = (SimpleNode) node.jjtGetChild(0);     
        String region = (String)sn_region.value(context);
        
        writer.write(region);
        
        return true;
    }

}
